import { App } from '@capacitor/app';
import { createAnimation } from '@ionic/react';

export class NavigationService {
  static async handleDeepLink(url: string) {
    // Handle deep link URLs
    const urlObj = new URL(url);
    const path = urlObj.pathname;
    const params = Object.fromEntries(urlObj.searchParams);
    
    return { path, params };
  }

  static getPageAnimation(direction: 'forward' | 'back') {
    const enteringAnimation = createAnimation()
      .duration(300)
      .easing('ease-in-out');

    const leavingAnimation = createAnimation()
      .duration(300)
      .easing('ease-in-out');

    if (direction === 'forward') {
      enteringAnimation
        .fromTo('transform', 'translateX(100%)', 'translateX(0)')
        .fromTo('opacity', '0.8', '1');

      leavingAnimation
        .fromTo('transform', 'translateX(0)', 'translateX(-100%)')
        .fromTo('opacity', '1', '0.8');
    } else {
      enteringAnimation
        .fromTo('transform', 'translateX(-100%)', 'translateX(0)')
        .fromTo('opacity', '0.8', '1');

      leavingAnimation
        .fromTo('transform', 'translateX(0)', 'translateX(100%)')
        .fromTo('opacity', '1', '0.8');
    }

    return { enteringAnimation, leavingAnimation };
  }
}